<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
                template="../template/layout.xhtml">

    <ui:define name="title">
        Add a task
    </ui:define>
    <ui:define name="content">
        <section class="admin add-task admin-form">
            <h:form id="task-add-form">
                <h2>Create a new task</h2>
                <div class="line">
                    <h:inputText value="#{adminTaskBean.task.title}"
                                 id="title"
                                 p:placeholder="Title"
                                 p:required="required"
                                 p:autofocus="autofocus" />
                    <span class="error red"><h:message for="title" /></span>
                </div>
                <div class="line">
                    <label for="deadlineDate">Deadline</label>
                    <span style="float: right;">
                        <h:inputText value="#{adminTaskBean.tmpDate}"
                                     id="deadlineDate"
                                     p:type="date"
                                     p:required="required"
                                     p:placeholder="YYYY-MM-DD" />
                        <h:inputText value="#{adminTaskBean.tmpTime}"
                                     id="deadlineTime"
                                     p:type="time"
                                     p:required="required"
                                     p:placeholder="HH:MM" />
                    </span>
                    <span class="error red"><h:message for="deadlineDate" /></span>
                </div>
                <div class="line">
                    <h:inputTextarea value="#{adminTaskBean.task.description}"
                                     id="description"
                                     p:placeholder="Description" />
                    <span class="error red"><h:message for="description" /></span>
                </div>
                <div class="line">
                    <p>Choose your contributors:<br />
                        <h:dataTable value="#{adminTaskBean.users}" var="user" id="tableUser" class="select-checkbox">
                            <h:column>
                                <h:selectBooleanCheckbox value="#{adminTaskBean.checked[user]}" onclick="this.checked = !this.checked;" />
                            </h:column>
                            <h:column class="name">
                                <f:facet name="header" class="name">Name</f:facet>
                                <span class="name no-overflow">#{user.firstname} #{user.lastname}</span>
                            </h:column>
                            <h:column class="email">
                                <f:facet name="header">Email</f:facet>
                                <span class="email no-overflow">#{user.email}</span>
                            </h:column>
                            <h:column class="role">
                                <f:facet name="header">Role</f:facet>
                                <span class="role no-overflow">#{user.roleName}</span>
                            </h:column>
                        </h:dataTable></p>
                </div>
                <div class="submit">
                    <h:commandButton value="Submit" action="#{adminTaskBean.addTask}" class="button" />
                </div>
            </h:form>
        </section>
    </ui:define>
</ui:composition>
